﻿using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace ERPStore.QuoteCart.Repositories.Mapping
{
	public class QuoteCartMap : EntityTypeConfiguration<Datas.QuoteCart>
	{
		public QuoteCartMap()
		{
			// Primary Key
			this.HasKey(t => t.Id);
            this.Property(e => e.Id)
                .IsRequired()
                .HasDatabaseGeneratedOption(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.Identity);

			// Properties
			this.Property(t => t.VisitorId)
				.IsRequired()
				.HasMaxLength(40);
				
			this.Property(t => t.CustomerDocumentReference)
				.HasMaxLength(100);
				
			this.Property(t => t.Code)
				.IsRequired()
				.HasMaxLength(40);
				
			this.Property(t => t.LastPage)
				.HasMaxLength(255);
				
			this.Property(t => t.LeadSourceInfo)
				.HasMaxLength(512);
				
			this.Property(t => t.LeadSourceId)
				.HasMaxLength(50);
				
			this.Property(t => t.RevisionId)
				.IsRequired()
				.IsFixedLength()
                .IsConcurrencyToken()
                .HasDatabaseGeneratedOption(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.Computed)
				.HasMaxLength(8);

			this.ToTable("QuoteCart");
		}
	}
}

